/**
x * @discription：
 * @author Administrator
 * @date 2025年8月26日
 */
package org.ruoyi.graph2.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.graph2.service.impl.GraphBase2ServiceImpl;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @discription：
 * @author Administrator
 * @date 2025年8月26日
 */
@SaIgnore
@RestController
@RequestMapping("/api/graphGraph2")
@RequiredArgsConstructor
public class GraphBase2Controller {

	private final GraphBase2ServiceImpl	graphBase2Service;

	/**
	 * 上传 word 文件
	 *
	 * @param file
	 * @return
	 * @throws Exception
	 */
	@PostMapping("/uploadWord")
	public R uploadWord(String title, MultipartFile file) throws Exception {
		return graphBase2Service.uploadWord(title, file);
	}

	/**
	 * 获取知识库的图谱数据
	 */
	@Operation(summary = "获取知识库图谱")
	@GetMapping("/{graphBaseId}")
	public R<Map<String, Object>> queryGraphByKnowledge(
		@PathVariable long graphBaseId,
		@RequestParam(defaultValue = "100") Integer limit) {

		return graphBase2Service.queryGraphByKnowledge(graphBaseId, limit);
	}

	/**
	 * 编辑后保存图谱
	 * @param graphBaseId
	 * @param graphJson
	 * @return
	 */
	@PutMapping("/{graphBaseId}")
	public R saveeGraph(@PathVariable long graphBaseId, @RequestBody String graphJson) {
		return graphBase2Service.saveGraph(graphBaseId, graphJson);
	}

	/**
	 * 删除图谱
	 *
	 * @param graphBaseId
	 * @return
	 */
	@DeleteMapping("/{graphBaseId}")
	public R deleteGraph(@PathVariable long graphBaseId) {
		return graphBase2Service.deleteGraph(graphBaseId);
	}
}
